﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using UAXInversionesWeb.logicaNegocio;

namespace UAXInversionesWeb.supervisor
{
    public partial class InformeHistoricoBolsa : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {

        }

        protected void calendario_SelectionChanged(object sender, EventArgs e)
        {
            if (HttpContext.Current.Session["identificador"] != null)
            {
                String fechaI = calendario.SelectedDate.ToString("yyyy" + "/" + "MM" + "/" + "dd");
                inicio.Text = fechaI;
            }
        }

        protected void calendario2_SelectionChanged(object sender, EventArgs e)
        {
            if (HttpContext.Current.Session["identificador"] != null)
            {
                String fechaF = calendario2.SelectedDate.ToString("yyyy" + "/" + "MM" + "/" + "dd");
                final.Text = fechaF;
                Acciones[] a = Proxy.obtenerInformeHistoricoBolsa(fechaF, inicio.Text);
                if (a.Length > 0)
                {
                    mensaje.Text = "";
                    TableRow row;

                    TableCell cell, cell2, cell3, cell4, cell5;

                    for (int i = 0; i < a.Length; i++)
                    {
                        row = new TableRow();
                        if (i % 2 != 0)
                        {
                            row.BackColor = System.Drawing.Color.FromArgb(240, 244, 247);
                        }

                        cell = new TableCell();
                        cell.HorizontalAlign = HorizontalAlign.Left;
                        cell.Text = a[i].getIdCliente().ToString();
                        row.Cells.Add(cell);

                        cell2 = new TableCell();
                        cell2.Text = a[i].getFechaOperacion().ToString("dd/MM/yyyy");
                        row.Cells.Add(cell2);

                        cell3 = new TableCell();
                        cell3.HorizontalAlign = HorizontalAlign.Right;
                        cell3.Text = a[i].getEmpresaCotizante();
                        row.Cells.Add(cell3);

                        cell4 = new TableCell();
                        cell4.HorizontalAlign = HorizontalAlign.Right;
                        cell4.Text = a[i].getNumeroDeAcciones().ToString();
                        row.Cells.Add(cell4);

                        cell5 = new TableCell();
                        cell5.HorizontalAlign = HorizontalAlign.Right;
                        cell5.Text = a[i].getValor().ToString("N") + "€";
                        row.Cells.Add(cell5);
                        Table1.Rows.Add(row);
                    }
                }
            }
        }
    }
}
